<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<table>
			<tr></tr>
		</table>
		<script src="../js/jquery-3.5.1.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			/*
				result：响应的内容。一般都是json格式的字符串。没有做JSON.parse()处理
				suc：请求是否成功的文字信息
				response：整个响应对象
			*/
			$.get("data.json", function(result, suc, response) {
				console.log(result, suc, response);
			});
			$.get("http://192.168.1.138:8080/demo?account=haha&password=123", function(result, suc, response) {
				console.log(result, suc, response); 
			});
			//错误演示
			// $.get("http://localhost:8080/postdemo", function(result, suc, response) {
			// 	console.log(result, suc, response);
			// });
			//错误演示
			// $.get("http://192.192.1.1:8080/data111.json", function(a, b, c, d, e) {
			// 	console.log(a, b, c, d, e);
			// });
			$.post("http://192.168.1.138:8080/postdemo", {
				account: "hehe",
				password: "123"
			}, function(result, suc, response) {
				console.log(result, suc, response); 
				console.log(typeof result);
				let json = JSON.parse(result);
				console.log(json);
				console.log(json.value;
				$(function(){
					
				})
			});
			
			//练习ajax，请求本地json文件、192.168.1.138服务器的get请求和post请求
			//并且将post的返回结果显示在table上
		</script>
	</body>
</html>
